package com.lzh.chatnote.user.dao;

import com.lzh.chatnote.user.domain.entity.Permission;
import com.lzh.chatnote.user.mapper.PermissionMapper;
import com.lzh.chatnote.user.service.PermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author lzh
 * @since 2025-10-09
 */
@Service
public class PermissionDao extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {

    public List<String> queryPermission(List<Long> userPermissionIds) {
        return Optional.ofNullable(lambdaQuery()
                .in(Permission::getId, userPermissionIds)
                .list()).orElse(Collections.emptyList())
                .stream()
                .map(Permission::getPermission)
                .collect(Collectors.toList());
    }
}
